home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / windownt / perlnt.zip / README < prev    next >
Text File  |  1993-07-25  |  8KB  |  203 lines

  1. Perl for NT
  2.  
  3.     Copyright (c) 1993, Intergraph Corporation
  4.  
  5.     You may distribute under the terms of either the GNU General Public
  6.     License or the Artistic License, as specified in the README file.
  7.  
  8.  
  9. What follows is my port of Perl to NT. It is based on perl version
  10. 4.036 and supports most of the base language. Winsock support is
  11. included.  This port has been in use at Intergraph for little over a
  12. month and has experienced no major crashes. Supplied with the source
  13. patches is the test suite that we've been using to prevent
  14. regressions. It is a modified version of the stock perl test suite,
  15. using a different driver (testnt.cmd) and a different test file
  16. extension (.nt instead of .t).
  17.  
  18. DISCLAIMER
  19.  
  20. This code is furnished on an as-is basis, with no support implied.
  21. You are free to modify and redistribute the code to your hearts
  22. content as long as you give credit where credit's due. I will gladly
  23. accept bug reports via email, but will not commit to fixing any of
  24. these bugs. I'll try, but my time is not my own...
  25.  
  26. END DISCLAIMER
  27.  
  28. This port is NOT a client of the POSIX sub-system for NT. If I had
  29. used POSIX, then Perl would be pretty crippled, with no networking
  30. support and no room to grow.
  31.  
  32. The main differences between a unix port of perl and the NT port are:
  33.  
  34.     - No shell
  35.     - No fork
  36.     - System calls (syscall, fcntl, ioctl, etc. missing)
  37.     - No Set-uid bit
  38.     - Ownership (uid's, groups, etc.)
  39.     - No inodes in stat
  40.     - System info (stored in registry instead of /etc/*)
  41.  
  42. (For a quick synopsis on what is supported, check out the file
  43. status.txt).
  44.  
  45. Having no shell makes wildcard expansion strange and it also causes
  46. difficulties with perl scripts specified on the command line. Rather
  47. than using the shell for wildcard expansion, it's better to use
  48. globbing, which is done by running perlglob.exe. Later I'd like  to
  49. put globbing in the interpreter (it would be fairly easy with
  50. FindFirstFile() and FindNextFile() doing the wildcard expansion) but I
  51. didn't have time before making my release date.
  52.  
  53. Cmd.exe, NT's sorry excuse for a command interpreter, does not treat
  54. quotes similarly to any unix shell. In particular, single quotes are
  55. not treated as quotes, merely as individual characters. This is why I
  56. ignore the argc and argv passed to main at program startup and
  57. re-parse the command line.
  58.  
  59. Fork is not there (never had it, never will) and I haven't added an
  60. explicit mechanism to create a process (although this should be
  61. trivial using the usersub mechanism). The only way to create processes
  62. at present are with back-ticks, open, or system. Since there is no way
  63. to create an independent process, pipe is not really useful and is not
  64. supported.
  65.  
  66. Readdir and friends aren't provided by NT, so I stole Diomidis
  67. Spinellis idea for DOS and reworked it for NT. All the work is done in
  68. opendir, which reads all the filenames in the opened directory into a
  69. string table. Readdir and friends then get strings from this table.
  70. It's not optimal, but it works for me.
  71.  
  72. Winsock only supports AF_INET sockets and those sockets only support
  73. send and recv (no read or write). Socketpair is not there, since
  74. winsock sockets are not inheritable (they have both a user and kernel
  75. component). I had to fake out fdopen, since NT won't let you fdopen a
  76. socket.
  77.  
  78. I also had to fake up a wrapper for strerror, since the one supplied
  79. with NT doesn't know about socket error values. Since winsock routines
  80. don't put their error values in errno, I put wrappers around the
  81. socket calls to update errno if they had an error. The wrappers also
  82. allow a lazy initialization of the socket system, only calling
  83. WSAStartup() if a socket routine is called.
  84.  
  85. On an up note, this port includes support for access to the NT
  86. registry database. All of the Registry API functions, with the
  87. exception of RegNotifyChangeKeyValue (hey, I didn't name these things!
  88. Talk to Dave "Mr Verbose" Cutler!) were implemented. For information
  89. on what arguments they expect, read the file registry.txt. For
  90. information on the actual API's see the Win32 API Reference help file,
  91. included with the SDK for NT.
  92.  
  93. INSTALLATION
  94.  
  95. This distribution comes as four shar files (shell archives). I'm
  96. assuming that you've got access to a unix system as well as an NT
  97. system. Unless someone has ported /bin/sh or /bin/ksh to NT (MKS are
  98. you listening?) as well as Larry Wall's patch program, you'll need
  99. unix to get set up.
  100.  
  101. To set up a source tree that will build under NT, make a directory on
  102. your unix system (we'll call it ~ntperl), copy the shar files into it,
  103. and then run /bin/sh on each of the pieces. You should end up with a
  104. directory that contains the files:
  105.  
  106.         README
  107.         eg
  108.         lib
  109.         patches
  110.         registry.txt
  111.         regupdat
  112.         relnotes.txt
  113.         src
  114.         status.txt
  115.         t
  116.         usersubs.txt
  117.  
  118. Eg, lib, src, and t are directories. Patches is a file of context
  119. diffs against the stock 4.036 source distribution of perl. The .txt
  120. files are text files describing various parts of the port. regupdat is
  121. a perl script that is used to update the NT registry database.
  122.  
  123. Now cd to a directory containing the vanilla source to perl (don't use
  124. your unix source dir, as we're about to make some changes...). Type
  125. the following command:
  126.  
  127.     $ patch < ~ntperl/patches
  128.  
  129. This will go through and make the same modifications that I had to
  130. make to get perl to run. Once this is complete, copy the contents of
  131. ~ntperl/src into your current directory. Now copy this tree to an NT
  132. system and you should be able to build it by typing 'nmake'.
  133.  
  134. When you've successfully built perl, you should have two executables,
  135. perl.exe and perlglob.exe. You can test the functionality of perl
  136. using the files contained in the 't' directory that came with the NT
  137. distribution. Type the command 'testnt' in that directory and the test
  138. suite will run.
  139.  
  140. Once it looks like perl is running, decide where you'd like to keep
  141. the executables, the library scripts, and any other scripts that you
  142. might have and create a directory with the following sub directories:
  143.  
  144.         bin
  145.         lib
  146.         eg
  147.  
  148. Copy the executables into bin, the lib directory from the NT
  149. distribution into lib, and the eg directory from the NT distribution
  150. into eg. Then run the perl script regupdat like so:
  151.  
  152.         perl regupdat <drive>:<directory>
  153.  
  154. This will install a set of keys in your NT registry that perl will use
  155. to locate the binaries and library files. If you want to use a
  156. different key string than the one used in regupdat then you'll have to
  157. make the appropriate changes in nt.c.
  158.  
  159. Included with this release is my version of the perl test suite. I
  160. changed the driver name to testnt.cmd and the test extension from .t
  161. to .nt. I did this so it would be easy for me to see what changes I
  162. made from the unix test suite.
  163.  
  164. Also included is a version of find.pl named ntfind.pl. It's a quick
  165. hack that works with NT. I don't claim that it's optimal. Not all of
  166. the routines in lib have been modified to work with NT.  As I modify
  167. them for NT, I'll post them to comp.lang.perl. If someone beats me to
  168. it, I'd appreciate a copy.
  169.  
  170. POSSIBLE FUTURE ENHANCEMENTS
  171.  
  172. I'd like to add a "spawn" facility that would allow a perl program to
  173. start a process for two-way communications. Something like this:
  174.  
  175.         pipe (MY_R, ITS_W);
  176.         pipe (ITS_R, MY_R);
  177.         &spawn ("foo.exe", "-v", ITS_R, ITS_W, ITS_W);
  178.         close(ITS_R);
  179.         close(ITS_W);
  180.  
  181. Where the ITS_* handles are stdin, stdout, and stderr for the spawned
  182. process. I'd welcome a discussion on how this would best be
  183. implemented. Also, once winsock sockets are inheritable, we'd be able
  184. to implement socketpair and use it.
  185.  
  186. I'd also like to spif up the Registry access routines to return arrays
  187. in the proper context.
  188.  
  189. It would sure be nice if we could pop up a dialog box...
  190.  
  191. Oh well, just dreaming. My manager has a list of stuff that will keep
  192. me busy for the rest of the year. But in my COPIOUS spare time, I'll
  193. keep looking at Perl for NT...
  194.  
  195. --------------------------------------------------------------------
  196. Clark Williams
  197. Software Development Tools
  198. Intergraph Corporation
  199. jcwillia@ingr.com
  200.  
  201.  
  202.  
  203.